/*
 *	AUTHOR:      weifeng
 *	QQ:          845882161
 *	EMAIL:       845882161@qq.com
 *	VERSION:     2016-07-22
 *	网站主题颜色   #0000cc
 *	稍暗         #00009b
 */
 
 // 首页公告切换
function tab_(oUlId, oDivId) {
    var oUl = document.getElementById(oUlId);
    var oDiv = document.getElementById(oDivId);
    var oLi = oUl.getElementsByTagName('li');
    var oShow = oDiv.getElementsByTagName('ul');

    for (var i = 0; i < oLi.length; i++) {
        oLi[i].index = i;
        oLi[i].onmouseover = function () {
            for (var i = 0; i < oLi.length; i++) {
                oLi[i].className = '';
                oShow[i].style.display = 'none';
            }
            this.className = 'active';
            oShow[this.index].style.display = 'block';
        }
    }

}
//banner图轮播
$(function () {
    (function () {
        var len = $("#idNum > li").length; var index = 0; var adTimer; var adwidth = $("#idTransformView").width();
        $("#idNum li").mouseover(function () {
            index = $("#idNum li").index(this);
            showImg(index);
        }).eq(0).mouseover();
        //滑入 停止动画，滑出开始动画.
        $("#idTransformView").hover(function () {
            clearInterval(adTimer);
        }, function () {
            adTimer = setInterval(function () {
                showImg(index)
                index++;
                if (index == len) { index = 0; }
            }, 2000);
        }).trigger("mouseleave");
        function showImg(index) {
            $("#idSlider").stop(true, false).animate({ left: -adwidth * index }, 500);
            $("#idNum li").removeClass("on").eq(index).addClass("on");
        }
    } ());
});
//最新供应
window.onload = function () {
    function startmarquee(lh, speed, delay) {
        var p = false;
        var t;
        var o = document.getElementById("marqueebox");
        if (o != null) {
            o.innerHTML += o.innerHTML;
            o.style.marginTop = 0;
            o.onmouseover = function () { p = true; }
            o.onmouseout = function () { p = false; }
            function start() {
                t = setInterval(scrolling, speed);
                if (!p) o.style.marginTop = parseInt(o.style.marginTop) - 1 + "px";
            }
            function scrolling() {
                if (parseInt(o.style.marginTop) % lh != 0) {
                    o.style.marginTop = parseInt(o.style.marginTop) - 1 + "px";
                    if (Math.abs(parseInt(o.style.marginTop)) >= o.scrollHeight / 2) o.style.marginTop = 0;
                } else {
                    clearInterval(t);
                    setTimeout(start, delay);
                }
            }
            setTimeout(start, delay);
        }
    }
    startmarquee(32, 15, 1000);
}

//浮动导航
$(function () {
    var wtop = $(window).height();
    $(window).scroll(function () {
        var sltop = $(this).scrollTop();
        if (sltop > wtop) {
            $(".floatnav").show();
        }
        else {
            $(".floatnav").hide();
        }
    })
    $(".floatnav ul li a").mouseenter(function () {
        $(this).children(".txt").show();
    })
    $(".floatnav ul li a").mouseleave(function () {
        $(this).children(".txt").hide();
    })
})

// 左侧弹出菜单
$(function () {
    $("#prod ").mouseenter(function () {
        $("#prod #nav").show();
    })
    $("#prod").mouseleave(function () {
        $("#prod #nav").hide();
    })

})

/*tab选项卡*/
$(function () {
    var $tab_nav = $(".tab_nav ul li");
    $tab_nav.mouseenter(function () {
        $(this).addClass("selected").siblings().removeClass("selected");
        var index = $tab_nav.index(this);
        $("div>.tab_box > ul").eq(index).show().siblings().hide();
    })
});